<?php
if (isset($_POST['SearchValue'])) {$_GET['SearchValue'] = $_POST['SearchValue'];}

$GETActInfo = $GLOBALS['MYT']->db_array("SELECT FraID, FraOrigen0, FraReferenciaAg, FraAlbaran, FraStatus, FraFechaIngreso, FraModo FROM facturas WHERE FraID = ".$_GET['SearchValue']);
if (isset($GETActInfo[1]) && $GETActInfo[1]['FraModo'] == 1) {
    echo '<div id="OR_SCHAction" class="Alert">';
    form_pr('pp_act', '', '', 'post');
    mn_field('hidden', 'ED', 'FraID', $GETActInfo[1]['FraID'], '', '', '', '');
    mn_field('hidden', 'ED', 'FraStatus', '', '', '', '', '');
    mn_field('hidden', 'ED', 'ACT_TYPE', 1, '', '', '', '');
    if ($GETActInfo[1]['FraStatus'] == 9 || $GETActInfo[1]['FraStatus'] == 1) {
        $GetHistory = $GLOBALS['MYT']->db_array("SELECT * FROM hd_historiagiros WHERE edg_Operacion = {$GETActInfo[1]['FraID']}");
        echo 'Informação do cancelamento: ' . $GetHistory[1]['edg_ID'];

        echo 'Data: ' . $GetHistory[1]['edg_FechaHora'];
        echo '<p>Usuario: ' . $GetHistory[1]['edg_Usuario'];
        echo '<p>Motivo: ' . $GetHistory[1]['edg_Motivo'];
    } elseif ($GETActInfo[1]['FraAlbaran'] == 0) {
        mn_field('hidden', 'ED', 'ACT_TYPE', 2, '', '', '', '');
        echo 'Não é possivel cancelar esta remessa, apenas é possivel anular.';
        echo '<p>Motivo para anulamento: ';
        mn_field('text', 'ED', 'sch_Information', '', '200', '50', '', '');
        mn_field('hidden', 'ED', 'sch_STATUS', '1', '', '', '', '');
        mn_field('button', 'ED', 'ORSCH_GO', 'Continuar', '', '', '', '" onclick="
		document.pp_act.FraStatus.value=document.pp_act.sch_STATUS.value;
		document.pp_act.action=\'_response/call.php?get=Operative/remittance&OR_CH\';
		subform(\'pp_act\',\'OR_SCHAction\');');
    } else {
        echo 'Numero de Operacao: ' . $GETActInfo[1]['FraID'] . '<br>
                    Referencia da Agencia: ' . $GETActInfo[1]['FraOrigen0'] . '-' . $GETActInfo[1]['FraReferenciaAg'] . '<br>
                    Data de Balcao: ' . $GETActInfo[1]['FraFechaIngreso'] . '<br>
                    Vai cancelar esta remessa, indique um motivo para o cancelamento: ';
        mn_field('text', 'ED', 'sch_Information', '', '200', '50', '', '');

        echo '<p>Tipo de cancelamento: ';
        $qr_cnltype = "Cancelamento;Devolucao#10;21";
        mn_field('hselect', 'ED', 'cnl_Type', 10, $qr_cnltype, '', '', '');

        mn_field('hidden', 'ED', 'sch_STATUS', '9', '', '', '', '');
        mn_field('button', 'ED', 'ORSCH_GO', 'Continuar', '', '', '', '" onclick="
		document.pp_act.FraStatus.value=document.pp_act.sch_STATUS.value;
		document.pp_act.action=\'_response/call.php?get=Operative/remittance&OR_CH\';
		subform(\'pp_act\',\'OR_SCHAction\');');
        echo '</div>';
    }
} elseif (isset($GETActInfo[1]) && $GETActInfo[1]['FraModo'] == 2) {
    $_GET['ActID'] = $GETActInfo[1]['FraStatus'];
    $_GET['NewFlg'] = 18;
    include $GLOBALS['ROO'].'Modules/Operative/frm_transferaction.php';
} else {
    echo 'Nao foi encontrada remessa.';
}
?>
<script charset="utf-8" type="text/javascript">
    Ext.onReady(function(){
        Ext.getCmp('win-statusbar').setStatus({text: 'Pronto'});
        Ext.getCmp('win-statusbar').Close();
    });
</script>